home *** CD-ROM | disk | FTP | other *** search
- function isEmpty(obj,str)
- {
- if(obj.value=="")
- {
- alert(str);
- obj.focus();
- return true;
- }
- else
- return false;
- }
-
- function numOnly(obj,strNum)
- {
- var val=obj.value;
- var flg=true;
- for(i=0; i<val.length; i++)
- {
- if(val.charCodeAt(i)>47 && val.charCodeAt(i)<58) {;}
- else {
- flg=false;
- alert(strNum);
- obj.value="";
- obj.focus();
- break;
- }
- }
-
- return flg;
- }
-
-
- function isZero(obj,str)
- {
- var temp=obj.value;
- for(i=0; i<temp.length; i++)
- {
- if(temp.charAt(i)=='0')
- {
- var temp1=temp;
- temp=temp.substring(i+1,temp.length);
- if(temp1.charAt(i+1)!='0') break;
- }
- else break;
- }
- if(parseInt(temp)<=0 || temp=="")
- {
- alert(str);
- obj.value="";
- obj.focus();
- return true;
- }
- else
- return false;
- }
-
- function chrOnly(obj,strChr)
- {
- var val=obj.value;
- var flg=true;
- for(i=0; i<val.length; i++)
- {
- if(val.charCodeAt(i)==32 || (val.charCodeAt(i)>64 && val.charCodeAt(i)<91) || (val.charCodeAt(i)>96 && val.charCodeAt(i)<123)){;}
- else
- {
- flg=false;
- alert(strChr);
- obj.value="";
- obj.focus();
- break;
- }
- }
-
- return flg;
- }
-
-
- function isSplChr(obj,strChr)
- {
- var val=obj.value;
- var flg=false;
- for(i=0; i<val.length; i++)
- {
- if(val.charCodeAt(i)==62 || val.charCodeAt(i)==34)
- {
-
- flg=true;
- alert(strChr);
- obj.value="";
- obj.focus();
- break;
- }
- }
- return flg;
- }
-
- //by Sri on 28/12/2k
- //The error message is totally given by the caller. No concatenation
- function isEmptyS(obj,str)
- {
- if(obj.value=="")
- {
- alert(str);
- obj.focus();
- return true;
- }
- else
- return false;
- }
-
- //by Sri on 28/12/2k
- //The error message is totally given by the caller. No concatenation
- function numOnlyS(obj,strNum)
- {
- var val=obj.value;
- var flg=true;
- for(i=0; i<val.length; i++)
- {
- if(val.charCodeAt(i)>47 && val.charCodeAt(i)<58) {;}
- else {
- flg=false;
- alert(strNum);
- obj.value="";
- obj.focus();
- break;
- }
- }
-
- return flg;
- }
-
- //by Sri on 28/12/2k
- //Moved here to remove redundancy
- function checkEmail(obj)
- {
- var val=obj.value;
- if(val=="") return false;
- var atcount=0;
- var atpos=0;
- var atplace=true;
- var dotcount=0;
- var dotpos=0;
- var dotplace=true;
- var spacecount=0;
-
- for(i=0;i<val.length;i++)
- if(val.charAt(i)==" ")
- spacecount++;
-
- for(i=0;i<val.length;i++)
- {
- if(val.charAt(i)=="@")
- {
- atcount++;
- atpos=i;
- if(val.charAt(i-1)=="." || val.charAt(i+1)==".") atplace=false;
- if(i==0 || i==val.length-1) atplace=false;
- }
- else
- if(val.charAt(i)==".")
- {
- dotcount++;
- dotpos=i;
- if(i==0 || i==val.length-1) dotplace=false;
- }
- else
- if(val.charAt(i)==" ")
- {
- spacecount++;
- }
- }
- if(atcount==0 || atcount>1 || atplace==false || dotcount==0 || dotplace==false || spacecount>0 || dotpos<atpos)
- {
- alert(e8);
- obj.value="";
- obj.focus();
- return false;
- }
- else return true;
- }
-
- //by Sri on 28/12/2k
- //String concatenation removed
- function isZeroS(obj,str)
- {
- var temp=obj.value;
- for(i=0; i<temp.length; i++)
- {
- if(temp.charAt(i)=='0')
- {
- var temp1=temp;
- temp=temp.substring(i+1,temp.length);
- if(temp1.charAt(i+1)!='0') break;
- }
- else break;
- }
- if(parseInt(temp)<=0 || temp=="")
- {
- alert(str);
- obj.value="";
- obj.focus();
- return true;
- }
- else
- return false;
- }
-
- function rs(n,u,w,h,x)
- {
- args="width="+w+",height="+h+",resizable=yes,scrollbars=yes,status=0";
- remote=window.open(u,n,args);
- if (remote != null) {
- if (remote.opener == null)
- remote.opener = self;
- }
- if (x == 1) { return remote; }
- }
-
- function spaceChk(val,msg)
- {
- var nonblnk = 0
- for (i=0;i<val.length;i++)
- {
- if (val.substring(i,i+1) != " ")
- {
- nonblnk = 1
- break
- }
- }
- if (nonblnk == 0 )
- {
- alert(msg)
- return false
- }
- else
- {
- return true
- }
- }